package com.qqtop10.manager.controller;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qqtop10.manager.model.Balance;
import com.qqtop10.manager.model.PagingArgs;
import com.qqtop10.manager.model.Result;
import com.qqtop10.manager.service.BalanceService;

@RequestMapping("/manager/balance/")
@Controller
public class BalanceController extends BaseController{
	@Autowired
	private BalanceService balanceService;
	@RequestMapping("all.do")
	@ResponseBody
	public Result all(Balance input){
		try {
			input.setShopname(URLDecoder.decode(input.getShopname(),"UTF-8"));
			input.setAccount(URLDecoder.decode(input.getAccount(),"UTF-8"));
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		//System.out.println(input.getShopname());
		//System.out.println(new String(.getBytes("ISO8859-1","utf-8")));
		try {
			PagingArgs pagingArgs = getPagingArgs();
			int count = balanceService.count(input);
			List<Balance> list = balanceService.all(input, pagingArgs);
			return page(count, list);
		} catch (Exception e) {
			return excep(e);
			// TODO: handle exception
		}
	}
}
